<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />

<meta name="viewport" content="width=device-width, initial-scale=1">

<meta name="author" content="Aubrey Dugger, James McCreight, Alyssa Hendricks" />

<meta name="date" content="2017-05-01" />

<title>Collect USGS stream observations to evaluate streamflow simulation</title>



<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
div.sourceCode { overflow-x: auto; }
table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
  margin: 0; padding: 0; vertical-align: baseline; border: none; }
table.sourceCode { width: 100%; line-height: 100%; }
td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
td.sourceCode { padding-left: 5px; }
code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
code > span.dt { color: #902000; } /* DataType */
code > span.dv { color: #40a070; } /* DecVal */
code > span.bn { color: #40a070; } /* BaseN */
code > span.fl { color: #40a070; } /* Float */
code > span.ch { color: #4070a0; } /* Char */
code > span.st { color: #4070a0; } /* String */
code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
code > span.ot { color: #007020; } /* Other */
code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
code > span.fu { color: #06287e; } /* Function */
code > span.er { color: #ff0000; font-weight: bold; } /* Error */
code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
code > span.cn { color: #880000; } /* Constant */
code > span.sc { color: #4070a0; } /* SpecialChar */
code > span.vs { color: #4070a0; } /* VerbatimString */
code > span.ss { color: #bb6688; } /* SpecialString */
code > span.im { } /* Import */
code > span.va { color: #19177c; } /* Variable */
code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code > span.op { color: #666666; } /* Operator */
code > span.bu { } /* BuiltIn */
code > span.ex { } /* Extension */
code > span.pp { color: #bc7a00; } /* Preprocessor */
code > span.at { color: #7d9029; } /* Attribute */
code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
</style>



<link href="data:text/css;charset=utf-8,body%20%7B%0Abackground%2Dcolor%3A%20%23fff%3B%0Amargin%3A%201em%20auto%3B%0Amax%2Dwidth%3A%20700px%3B%0Aoverflow%3A%20visible%3B%0Apadding%2Dleft%3A%202em%3B%0Apadding%2Dright%3A%202em%3B%0Afont%2Dfamily%3A%20%22Open%20Sans%22%2C%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20Arial%2C%20sans%2Dserif%3B%0Afont%2Dsize%3A%2014px%3B%0Aline%2Dheight%3A%201%2E35%3B%0A%7D%0A%23header%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0A%23TOC%20%7B%0Aclear%3A%20both%3B%0Amargin%3A%200%200%2010px%2010px%3B%0Apadding%3A%204px%3B%0Awidth%3A%20400px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Aborder%2Dradius%3A%205px%3B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Afont%2Dsize%3A%2013px%3B%0Aline%2Dheight%3A%201%2E3%3B%0A%7D%0A%23TOC%20%2Etoctitle%20%7B%0Afont%2Dweight%3A%20bold%3B%0Afont%2Dsize%3A%2015px%3B%0Amargin%2Dleft%3A%205px%3B%0A%7D%0A%23TOC%20ul%20%7B%0Apadding%2Dleft%3A%2040px%3B%0Amargin%2Dleft%3A%20%2D1%2E5em%3B%0Amargin%2Dtop%3A%205px%3B%0Amargin%2Dbottom%3A%205px%3B%0A%7D%0A%23TOC%20ul%20ul%20%7B%0Amargin%2Dleft%3A%20%2D2em%3B%0A%7D%0A%23TOC%20li%20%7B%0Aline%2Dheight%3A%2016px%3B%0A%7D%0Atable%20%7B%0Amargin%3A%201em%20auto%3B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dcolor%3A%20%23DDDDDD%3B%0Aborder%2Dstyle%3A%20outset%3B%0Aborder%2Dcollapse%3A%20collapse%3B%0A%7D%0Atable%20th%20%7B%0Aborder%2Dwidth%3A%202px%3B%0Apadding%3A%205px%3B%0Aborder%2Dstyle%3A%20inset%3B%0A%7D%0Atable%20td%20%7B%0Aborder%2Dwidth%3A%201px%3B%0Aborder%2Dstyle%3A%20inset%3B%0Aline%2Dheight%3A%2018px%3B%0Apadding%3A%205px%205px%3B%0A%7D%0Atable%2C%20table%20th%2C%20table%20td%20%7B%0Aborder%2Dleft%2Dstyle%3A%20none%3B%0Aborder%2Dright%2Dstyle%3A%20none%3B%0A%7D%0Atable%20thead%2C%20table%20tr%2Eeven%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Ap%20%7B%0Amargin%3A%200%2E5em%200%3B%0A%7D%0Ablockquote%20%7B%0Abackground%2Dcolor%3A%20%23f6f6f6%3B%0Apadding%3A%200%2E25em%200%2E75em%3B%0A%7D%0Ahr%20%7B%0Aborder%2Dstyle%3A%20solid%3B%0Aborder%3A%20none%3B%0Aborder%2Dtop%3A%201px%20solid%20%23777%3B%0Amargin%3A%2028px%200%3B%0A%7D%0Adl%20%7B%0Amargin%2Dleft%3A%200%3B%0A%7D%0Adl%20dd%20%7B%0Amargin%2Dbottom%3A%2013px%3B%0Amargin%2Dleft%3A%2013px%3B%0A%7D%0Adl%20dt%20%7B%0Afont%2Dweight%3A%20bold%3B%0A%7D%0Aul%20%7B%0Amargin%2Dtop%3A%200%3B%0A%7D%0Aul%20li%20%7B%0Alist%2Dstyle%3A%20circle%20outside%3B%0A%7D%0Aul%20ul%20%7B%0Amargin%2Dbottom%3A%200%3B%0A%7D%0Apre%2C%20code%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0Aborder%2Dradius%3A%203px%3B%0Acolor%3A%20%23333%3B%0Awhite%2Dspace%3A%20pre%2Dwrap%3B%20%0A%7D%0Apre%20%7B%0Aborder%2Dradius%3A%203px%3B%0Amargin%3A%205px%200px%2010px%200px%3B%0Apadding%3A%2010px%3B%0A%7D%0Apre%3Anot%28%5Bclass%5D%29%20%7B%0Abackground%2Dcolor%3A%20%23f7f7f7%3B%0A%7D%0Acode%20%7B%0Afont%2Dfamily%3A%20Consolas%2C%20Monaco%2C%20%27Courier%20New%27%2C%20monospace%3B%0Afont%2Dsize%3A%2085%25%3B%0A%7D%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%7B%0Apadding%3A%202px%200px%3B%0A%7D%0Adiv%2Efigure%20%7B%0Atext%2Dalign%3A%20center%3B%0A%7D%0Aimg%20%7B%0Abackground%2Dcolor%3A%20%23FFFFFF%3B%0Apadding%3A%202px%3B%0Aborder%3A%201px%20solid%20%23DDDDDD%3B%0Aborder%2Dradius%3A%203px%3B%0Aborder%3A%201px%20solid%20%23CCCCCC%3B%0Amargin%3A%200%205px%3B%0A%7D%0Ah1%20%7B%0Amargin%2Dtop%3A%200%3B%0Afont%2Dsize%3A%2035px%3B%0Aline%2Dheight%3A%2040px%3B%0A%7D%0Ah2%20%7B%0Aborder%2Dbottom%3A%204px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Apadding%2Dbottom%3A%202px%3B%0Afont%2Dsize%3A%20145%25%3B%0A%7D%0Ah3%20%7B%0Aborder%2Dbottom%3A%202px%20solid%20%23f7f7f7%3B%0Apadding%2Dtop%3A%2010px%3B%0Afont%2Dsize%3A%20120%25%3B%0A%7D%0Ah4%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23f7f7f7%3B%0Amargin%2Dleft%3A%208px%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Ah5%2C%20h6%20%7B%0Aborder%2Dbottom%3A%201px%20solid%20%23ccc%3B%0Afont%2Dsize%3A%20105%25%3B%0A%7D%0Aa%20%7B%0Acolor%3A%20%230033dd%3B%0Atext%2Ddecoration%3A%20none%3B%0A%7D%0Aa%3Ahover%20%7B%0Acolor%3A%20%236666ff%3B%20%7D%0Aa%3Avisited%20%7B%0Acolor%3A%20%23800080%3B%20%7D%0Aa%3Avisited%3Ahover%20%7B%0Acolor%3A%20%23BB00BB%3B%20%7D%0Aa%5Bhref%5E%3D%22http%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0Aa%5Bhref%5E%3D%22https%3A%22%5D%20%7B%0Atext%2Ddecoration%3A%20underline%3B%20%7D%0A%0Acode%20%3E%20span%2Ekw%20%7B%20color%3A%20%23555%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Edt%20%7B%20color%3A%20%23902000%3B%20%7D%20%0Acode%20%3E%20span%2Edv%20%7B%20color%3A%20%2340a070%3B%20%7D%20%0Acode%20%3E%20span%2Ebn%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Efl%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Ech%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Est%20%7B%20color%3A%20%23d14%3B%20%7D%20%0Acode%20%3E%20span%2Eco%20%7B%20color%3A%20%23888888%3B%20font%2Dstyle%3A%20italic%3B%20%7D%20%0Acode%20%3E%20span%2Eot%20%7B%20color%3A%20%23007020%3B%20%7D%20%0Acode%20%3E%20span%2Eal%20%7B%20color%3A%20%23ff0000%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%0Acode%20%3E%20span%2Efu%20%7B%20color%3A%20%23900%3B%20font%2Dweight%3A%20bold%3B%20%7D%20%20code%20%3E%20span%2Eer%20%7B%20color%3A%20%23a61717%3B%20background%2Dcolor%3A%20%23e3d2d2%3B%20%7D%20%0A" rel="stylesheet" type="text/css" />

</head>

<body>




<h1 class="title toc-ignore">Collect USGS stream observations to evaluate streamflow simulation</h1>
<h4 class="author"><em>Aubrey Dugger, James McCreight, Alyssa Hendricks</em></h4>
<h4 class="date"><em>2017-05-01</em></h4>



<div id="background" class="section level1">
<h1>Background</h1>
<p>USGS streamflow observations are a primary source of hydrologic information and often used for validation and calibration of hydrlogic models. Recently, web services have been developed at <a href="http://waterdata.usgs.gov/nwis"><em>NWIS</em></a> and the <a href="http://cran.r-project.org/web/packages/dataRetrieval/index.html"><em>dataRetrieval</em></a> R package has emerged to make it easy to get USGS data into R.</p>
<p>This vignette demonstates some rwrfhydro tools to collect, store, and mainipulate USGS within a local database. This data is then used to evaluate model performance in estimating streamflow with and without overland, subsurface, and groundwater routing active. WRF-Hydro was run predict streamflow for Fourmile Creek at the Orodell USGS gage for the 2013 snowmelt period. NoahMP was used as the LSM and a 3-year spinup period was completed prior to the part of the simulation in the test case directory.</p>
<p>The fundamental layout of the local database is simply a directory containing:</p>
<ul>
<li>Metadata data base (metaDB): Organized hierarchically by HUC8 -&gt; product id -&gt; siteInfo, variableInfo, statisticInfo where the last three are information fields returned by dataRetrieval::readNWISuv. The information in this file is simply the aggregation of the metadata from all the data files also contained in the same directory.</li>
<li>Individual data files collected by HUC8: These contain both the meta data for the HUC8 (aggregated in the metadata DB) and all the previously retrieved data for the HUC8.</li>
</ul>
<p>Generally, there are two basic kinds of functions: “Get” and “Query”. Get functions use dataRetrieval functions to actually go out to NWIS and “get” data and metadata. Query functions query the local database. There are exceptions to this.</p>
</div>
<div id="setup" class="section level1">
<h1>Setup</h1>
<p>Load the rwrfhydro package.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(<span class="st">&quot;rwrfhydro&quot;</span>)</code></pre></div>
<p>Create a directory and path to where you want your database to be built:</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dbPath &lt;-<span class="st"> '~/wrfHydroTestCases/usgsDb/'</span></code></pre></div>
</div>
<div id="discover-gage-locations-get-data-and-save-to-local-database." class="section level1">
<h1>Discover gage locations, get data, and save to local database.</h1>
<p>Perhaps you know the lat/lon of a gage (e.g. from frxst_pts_out.txt) and you need the HUC8. The <code>within</code> argument is taken to be in decimal degrees.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">stnDf &lt;-<span class="st"> </span><span class="kw">FindUsgsStns</span>(<span class="dt">stnLon=</span><span class="fl">254.67374999999998408</span>,
                      <span class="dt">stnLat=</span><span class="fl">40.018666670000001773</span>,
                      <span class="dt">within=</span>.<span class="dv">001</span>)
<span class="kw">str</span>(stnDf)</code></pre></div>
<pre><code>## 'data.frame':    1 obs. of  13 variables:
##  $ stnLon       : num 255
##  $ stnLat       : num 40
##  $ within       : num 0.001
##  $ siteType     : chr &quot;ST&quot;
##  $ hasDataTypeCd: chr &quot;iv&quot;
##  $ agency_cd    : chr &quot;USGS&quot;
##  $ site_no      : chr &quot;06727500&quot;
##  $ station_nm   : chr &quot;FOURMILE CREEK AT ORODELL, CO&quot;
##  $ site_tp_cd   : chr &quot;ST&quot;
##  $ dec_lat_va   : num 40
##  $ dec_long_va  : num -105
##  $ colocated    : logi FALSE
##  $ queryTime    : POSIXct, format: &quot;2017-05-01 16:43:05&quot;</code></pre>
<p>Now you have the site_no or station ID number, “06727500”. You could have also used <code>FindUsgsStns()</code> to reveal the gages in the HUC8, if you knew the HUC8 code. Because we organize the database by HUC8, we have a function to get HUC8 from station id. Then we get the above information for all locations in the HUC8.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">huc8 &lt;-<span class="st"> </span><span class="kw">GetSiteHuc</span>(stnDf<span class="op">$</span>site_no)
<span class="kw">str</span>(<span class="kw">FindUsgsStns</span>(<span class="dt">huc=</span>huc8))</code></pre></div>
<pre><code>## 'data.frame':    8 obs. of  11 variables:
##  $ huc8         : Factor w/ 1 level &quot;10190005&quot;: 1 1 1 1 1 1 1 1
##  $ siteType     : chr  &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; ...
##  $ hasDataTypeCd: chr  &quot;iv&quot; &quot;iv&quot; &quot;iv&quot; &quot;iv&quot; ...
##  $ agency_cd    : chr  &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; ...
##  $ site_no      : chr  &quot;06727410&quot; &quot;06730160&quot; &quot;06727500&quot; &quot;06730200&quot; ...
##  $ station_nm   : chr  &quot;FOURMILE CREEK AT LOGAN MILL ROAD NEAR CRISMAN, CO&quot; &quot;FOURMILE CANYON CREEK NEAR SUNSHINE, CO&quot; &quot;FOURMILE CREEK AT ORODELL, CO&quot; &quot;BOULDER CREEK AT NORTH 75TH ST. NEAR BOULDER, CO&quot; ...
##  $ site_tp_cd   : chr  &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; ...
##  $ dec_lat_va   : num  40 40.1 40 40.1 40.1 ...
##  $ dec_long_va  : num  -105 -105 -105 -105 -105 ...
##  $ colocated    : logi  FALSE FALSE FALSE FALSE FALSE FALSE ...
##  $ queryTime    : POSIXct, format: &quot;2017-05-01 16:43:05&quot; &quot;2017-05-01 16:43:05&quot; &quot;2017-05-01 16:43:05&quot; &quot;2017-05-01 16:43:05&quot; ...</code></pre>
<p>FindUsgsStns is a wrapper on dataRetrieval::whatNWISsites which has been written to focus on instantaneous values. (It is worth noting the flexibility and generality of the underlying function.)</p>
<p>Now pull the data for this HUC8. Currently, this grabs all available products for the HUC. Note that the HUC data are organized by product code (e.g. <code>00060</code>) then by <code>data</code> and <code>meta</code> in the returned list. (Also note that this command sometimes fails on the remote end and may need to be rerun.) In <code>meta</code>, siteInfo is the meta that we use in querying the local data base in commands shown below.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">coData &lt;-<span class="st"> </span><span class="kw">GetUsgsHucData</span>(<span class="dt">huc=</span>huc8)  ## this can take a little while...
<span class="kw">str</span>(coData)</code></pre></div>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">str</span>(coData)</code></pre></div>
<pre><code>## List of 2
##  $ 00060:List of 2
##   ..$ data:'data.frame': 1252525 obs. of  6 variables:
##   .. ..$ agency_cd       : chr [1:1252525] &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; ...
##   .. ..$ site_no         : chr [1:1252525] &quot;06724970&quot; &quot;06724970&quot; &quot;06724970&quot; &quot;06724970&quot; ...
##   .. ..$ dateTime        : POSIXct[1:1252525], format: &quot;2014-03-06 07:00:00&quot; &quot;2014-03-06 07:10:00&quot; &quot;2014-03-06 07:20:00&quot; &quot;2014-03-06 07:30:00&quot; ...
##   .. ..$ tz_cd           : chr [1:1252525] &quot;UTC&quot; &quot;UTC&quot; &quot;UTC&quot; &quot;UTC&quot; ...
##   .. ..$ X_00060_00011_cd: chr [1:1252525] &quot;A&quot; &quot;A&quot; &quot;A&quot; &quot;A&quot; ...
##   .. ..$ X_00060_00011   : num [1:1252525] 11 11 11 12 12 13 13 13 13 13 ...
##   ..$ meta:List of 3
##   .. ..$ siteInfo     :'data.frame': 8 obs. of  46 variables:
##   .. .. ..$ site_no              : chr [1:8] &quot;06724970&quot; &quot;06725450&quot; &quot;06727410&quot; &quot;06727500&quot; ...
##   .. .. ..$ agency_cd            : chr [1:8] &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; ...
##   .. .. ..$ dec_lat_va           : num [1:8] 40.1 40.2 40 40 40.1 ...
##   .. .. ..$ dec_long_va          : num [1:8] -105 -105 -105 -105 -105 ...
##   .. .. ..$ huc_cd               : chr [1:8] &quot;10190005&quot; &quot;10190005&quot; &quot;10190005&quot; &quot;10190005&quot; ...
##   .. .. ..$ site_tp_cd           : chr [1:8] &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; ...
##   .. .. ..$ state_cd             : chr [1:8] &quot;08&quot; &quot;08&quot; &quot;08&quot; &quot;08&quot; ...
##   .. .. ..$ station_nm           : chr [1:8] &quot;LEFT HAND CREEK AT HOVER ROAD NEAR LONGMONT, CO&quot; &quot;ST. VRAIN CREEK BELOW LONGMONT, CO&quot; &quot;FOURMILE CREEK AT LOGAN MILL ROAD NEAR CRISMAN, CO&quot; &quot;FOURMILE CREEK AT ORODELL, CO&quot; ...
##   .. .. ..$ tz_cd                : chr [1:8] &quot;MST&quot; &quot;MST&quot; &quot;MST&quot; &quot;MST&quot; ...
##   .. .. ..$ lat_va               : num [1:8] 400803 400927 400231 400107 400327 ...
##   .. .. ..$ long_va              : num [1:8] 1050751 1050055 1052154 1051934 1052056 ...
##   .. .. ..$ coord_meth_cd        : chr [1:8] &quot;N&quot; &quot;N&quot; &quot;M&quot; &quot;N&quot; ...
##   .. .. ..$ coord_acy_cd         : chr [1:8] &quot;M&quot; &quot;5&quot; &quot;1&quot; &quot;5&quot; ...
##   .. .. ..$ coord_datum_cd       : chr [1:8] &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; ...
##   .. .. ..$ dec_coord_datum_cd   : chr [1:8] &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; ...
##   .. .. ..$ district_cd          : chr [1:8] &quot;08&quot; &quot;08&quot; &quot;08&quot; &quot;08&quot; ...
##   .. .. ..$ county_cd            : chr [1:8] &quot;013&quot; &quot;123&quot; &quot;013&quot; &quot;013&quot; ...
##   .. .. ..$ country_cd           : chr [1:8] &quot;US&quot; &quot;US&quot; &quot;US&quot; &quot;US&quot; ...
##   .. .. ..$ land_net_ds          : chr [1:8] &quot;  SWSWS16 T02N  R69W  6&quot; &quot;  NWNWS09 T002N R068W&quot; &quot;  NWNES20 T01N  R71W&quot; &quot;  NWSES27 T001N R071W&quot; ...
##   .. .. ..$ map_nm               : chr [1:8] &quot;HYGIENE, CO&quot; &quot;LONGMONT, CO&quot; &quot;BOULDER, CO&quot; &quot;BOULDER, CO&quot; ...
##   .. .. ..$ map_scale_fc         : chr [1:8] &quot;  24000&quot; &quot;  24000&quot; &quot;  24000&quot; &quot;  24000&quot; ...
##   .. .. ..$ alt_va               : num [1:8] 4994 4852 6341 5750 6639 ...
##   .. .. ..$ alt_meth_cd          : chr [1:8] &quot;N&quot; &quot;M&quot; &quot;N&quot; &quot;M&quot; ...
##   .. .. ..$ alt_acy_va           : num [1:8] 4.3 10 4.3 15 4.3 10 10 4.3
##   .. .. ..$ alt_datum_cd         : chr [1:8] &quot;NAVD88&quot; &quot;NGVD29&quot; &quot;NAVD88&quot; &quot;NGVD29&quot; ...
##   .. .. ..$ basin_cd             : chr [1:8] &quot;06&quot; &quot;06&quot; &quot;&quot; &quot;06&quot; ...
##   .. .. ..$ topo_cd              : chr [1:8] &quot;&quot; &quot;&quot; &quot;C&quot; &quot;&quot; ...
##   .. .. ..$ instruments_cd       : chr [1:8] &quot;YNNNYNNNNNNNNNNNNNNNNNNNNNNNNN&quot; &quot;NNNNYNNNNNNNNNNNNNNNNNNNNNNNNN&quot; &quot;NNNNYNYNNYNNNNNNNNNNNNNNNNNNNN&quot; &quot;NNNNYNYNNYNNNNNNNNNNNNNNNNNNNN&quot; ...
##   .. .. ..$ construction_dt      : chr [1:8] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ inventory_dt         : chr [1:8] &quot;20140304&quot; &quot;&quot; &quot;20110317&quot; &quot;20110323&quot; ...
##   .. .. ..$ drain_area_va        : num [1:8] 71.6 423 19.2 24.2 1.8 307 447 NA
##   .. .. ..$ contrib_drain_area_va: num [1:8] NA NA NA NA NA NA NA NA
##   .. .. ..$ local_time_fg        : chr [1:8] &quot;Y&quot; &quot;Y&quot; &quot;Y&quot; &quot;Y&quot; ...
##   .. .. ..$ reliability_cd       : chr [1:8] &quot;U&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ gw_file_cd           : chr [1:8] &quot; Y&quot; &quot;NYNNNNNN&quot; &quot; Y&quot; &quot;NYNNNNNN&quot; ...
##   .. .. ..$ nat_aqfr_cd          : chr [1:8] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ aqfr_cd              : chr [1:8] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ aqfr_type_cd         : chr [1:8] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ well_depth_va        : num [1:8] NA NA NA NA NA NA NA NA
##   .. .. ..$ hole_depth_va        : num [1:8] NA NA NA NA NA NA NA NA
##   .. .. ..$ depth_src_cd         : chr [1:8] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ project_no           : chr [1:8] &quot;00001200&quot; &quot;&quot; &quot;000012000&quot; &quot;000012000&quot; ...
##   .. .. ..$ timeZoneOffset       : chr [1:8] &quot;-07:00&quot; &quot;-07:00&quot; &quot;-07:00&quot; &quot;-07:00&quot; ...
##   .. .. ..$ srs                  : chr [1:8] &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; ...
##   .. .. ..$ startTime            : POSIXct[1:8], format: &quot;2014-03-06 07:00:00&quot; &quot;2007-10-01 06:00:00&quot; &quot;2011-04-01 07:00:00&quot; &quot;2011-04-01 06:00:00&quot; ...
##   .. .. ..$ endTime              : POSIXct[1:8], format: &quot;2015-04-17 04:10:00&quot; &quot;2013-09-12 05:45:00&quot; &quot;2013-09-12 05:55:00&quot; &quot;2015-04-17 04:10:00&quot; ...
##   .. ..$ variableInfo :'data.frame': 1 obs. of  6 variables:
##   .. .. ..$ parameterCd   : chr &quot;00060&quot;
##   .. .. ..$ parameter_nm  : chr &quot;Streamflow, ft&amp;#179;/s&quot;
##   .. .. ..$ parameter_desc: chr &quot;Discharge, cubic feet per second&quot;
##   .. .. ..$ valueType     : chr &quot;Derived Value&quot;
##   .. .. ..$ param_units   : chr &quot;ft3/s&quot;
##   .. .. ..$ noDataValue   : logi NA
##   .. ..$ statisticInfo:'data.frame': 1 obs. of  2 variables:
##   .. .. ..$ statisticName: chr &quot;&quot;
##   .. .. ..$ statisticCd  : chr &quot;00011&quot;
##  $ 00065:List of 2
##   ..$ data:'data.frame': 64142 obs. of  6 variables:
##   .. ..$ agency_cd       : chr [1:64142] &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; ...
##   .. ..$ site_no         : chr [1:64142] &quot;06724970&quot; &quot;06724970&quot; &quot;06724970&quot; &quot;06724970&quot; ...
##   .. ..$ dateTime        : POSIXct[1:64142], format: &quot;2014-12-17 07:00:00&quot; &quot;2014-12-17 07:10:00&quot; &quot;2014-12-17 07:20:00&quot; &quot;2014-12-17 07:30:00&quot; ...
##   .. ..$ tz_cd           : chr [1:64142] &quot;UTC&quot; &quot;UTC&quot; &quot;UTC&quot; &quot;UTC&quot; ...
##   .. ..$ X_00065_00011_cd: chr [1:64142] &quot;P&quot; &quot;P&quot; &quot;P&quot; &quot;P&quot; ...
##   .. ..$ X_00065_00011   : num [1:64142] 6.48 6.49 6.48 6.49 6.49 6.49 6.48 6.48 6.48 6.48 ...
##   ..$ meta:List of 3
##   .. ..$ siteInfo     :'data.frame': 6 obs. of  46 variables:
##   .. .. ..$ site_no              : chr [1:6] &quot;06724970&quot; &quot;06727500&quot; &quot;06730160&quot; &quot;06730200&quot; ...
##   .. .. ..$ agency_cd            : chr [1:6] &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; &quot;USGS&quot; ...
##   .. .. ..$ dec_lat_va           : num [1:6] 40.1 40 40.1 40.1 40.1 ...
##   .. .. ..$ dec_long_va          : num [1:6] -105 -105 -105 -105 -105 ...
##   .. .. ..$ huc_cd               : chr [1:6] &quot;10190005&quot; &quot;10190005&quot; &quot;10190005&quot; &quot;10190005&quot; ...
##   .. .. ..$ site_tp_cd           : chr [1:6] &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; &quot;ST&quot; ...
##   .. .. ..$ state_cd             : chr [1:6] &quot;08&quot; &quot;08&quot; &quot;08&quot; &quot;08&quot; ...
##   .. .. ..$ station_nm           : chr [1:6] &quot;LEFT HAND CREEK AT HOVER ROAD NEAR LONGMONT, CO&quot; &quot;FOURMILE CREEK AT ORODELL, CO&quot; &quot;FOURMILE CANYON CREEK NEAR SUNSHINE, CO&quot; &quot;BOULDER CREEK AT NORTH 75TH ST. NEAR BOULDER, CO&quot; ...
##   .. .. ..$ tz_cd                : chr [1:6] &quot;MST&quot; &quot;MST&quot; &quot;MST&quot; &quot;MST&quot; ...
##   .. .. ..$ lat_va               : num [1:6] 400803 400107 400327 400306 400820 ...
##   .. .. ..$ long_va              : num [1:6] 1050751 1051934 1052056 1051042 1050113 ...
##   .. .. ..$ coord_meth_cd        : chr [1:6] &quot;N&quot; &quot;N&quot; &quot;G&quot; &quot;M&quot; ...
##   .. .. ..$ coord_acy_cd         : chr [1:6] &quot;M&quot; &quot;5&quot; &quot;S&quot; &quot;M&quot; ...
##   .. .. ..$ coord_datum_cd       : chr [1:6] &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD27&quot; ...
##   .. .. ..$ dec_coord_datum_cd   : chr [1:6] &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; &quot;NAD83&quot; ...
##   .. .. ..$ district_cd          : chr [1:6] &quot;08&quot; &quot;08&quot; &quot;08&quot; &quot;08&quot; ...
##   .. .. ..$ county_cd            : chr [1:6] &quot;013&quot; &quot;013&quot; &quot;013&quot; &quot;013&quot; ...
##   .. .. ..$ country_cd           : chr [1:6] &quot;US&quot; &quot;US&quot; &quot;US&quot; &quot;US&quot; ...
##   .. .. ..$ land_net_ds          : chr [1:6] &quot;  SWSWS16 T02N  R69W  6&quot; &quot;  NWSES27 T001N R071W&quot; &quot;      S09 T01N  R71W  6&quot; &quot;  SENWS13 T001N R070W&quot; ...
##   .. .. ..$ map_nm               : chr [1:6] &quot;HYGIENE, CO&quot; &quot;BOULDER, CO&quot; &quot;BOULDER, CO&quot; &quot;&quot; ...
##   .. .. ..$ map_scale_fc         : chr [1:6] &quot;  24000&quot; &quot;  24000&quot; &quot;  24000&quot; &quot;&quot; ...
##   .. .. ..$ alt_va               : num [1:6] 4994 5750 6639 5106 4860 ...
##   .. .. ..$ alt_meth_cd          : chr [1:6] &quot;N&quot; &quot;M&quot; &quot;N&quot; &quot;M&quot; ...
##   .. .. ..$ alt_acy_va           : num [1:6] 4.3 15 4.3 10 10 4.3
##   .. .. ..$ alt_datum_cd         : chr [1:6] &quot;NAVD88&quot; &quot;NGVD29&quot; &quot;NAVD88&quot; &quot;NGVD29&quot; ...
##   .. .. ..$ basin_cd             : chr [1:6] &quot;06&quot; &quot;06&quot; &quot;06&quot; &quot;&quot; ...
##   .. .. ..$ topo_cd              : chr [1:6] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ instruments_cd       : chr [1:6] &quot;YNNNYNNNNNNNNNNNNNNNNNNNNNNNNN&quot; &quot;NNNNYNYNNYNNNNNNNNNNNNNNNNNNNN&quot; &quot;NNNNYNNNNYNNNNNNNNNNNNNNNNNNNN&quot; &quot;YNNNYNNNNNNNNNNNNNNNNNNNNNNNNN&quot; ...
##   .. .. ..$ construction_dt      : chr [1:6] &quot;&quot; &quot;&quot; &quot;20120416&quot; &quot;&quot; ...
##   .. .. ..$ inventory_dt         : chr [1:6] &quot;20140304&quot; &quot;20110323&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ drain_area_va        : num [1:6] 71.6 24.2 1.8 307 447 NA
##   .. .. ..$ contrib_drain_area_va: num [1:6] NA NA NA NA NA NA
##   .. .. ..$ local_time_fg        : chr [1:6] &quot;Y&quot; &quot;Y&quot; &quot;Y&quot; &quot;Y&quot; ...
##   .. .. ..$ reliability_cd       : chr [1:6] &quot;U&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ gw_file_cd           : chr [1:6] &quot; Y&quot; &quot;NYNNNNNN&quot; &quot; Y&quot; &quot;NYNNNNNN&quot; ...
##   .. .. ..$ nat_aqfr_cd          : chr [1:6] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ aqfr_cd              : chr [1:6] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ aqfr_type_cd         : chr [1:6] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ well_depth_va        : num [1:6] NA NA NA NA NA NA
##   .. .. ..$ hole_depth_va        : num [1:6] NA NA NA NA NA NA
##   .. .. ..$ depth_src_cd         : chr [1:6] &quot;&quot; &quot;&quot; &quot;&quot; &quot;&quot; ...
##   .. .. ..$ project_no           : chr [1:6] &quot;00001200&quot; &quot;000012000&quot; &quot;000012000&quot; &quot;&quot; ...
##   .. .. ..$ timeZoneOffset       : chr [1:6] &quot;-07:00&quot; &quot;-07:00&quot; &quot;-07:00&quot; &quot;-07:00&quot; ...
##   .. .. ..$ srs                  : chr [1:6] &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; &quot;EPSG:4326&quot; ...
##   .. .. ..$ startTime            : POSIXct[1:6], format: &quot;2014-12-17 07:00:00&quot; &quot;2015-03-27 16:15:00&quot; &quot;2015-03-27 19:35:00&quot; &quot;2014-12-17 07:00:00&quot; ...
##   .. .. ..$ endTime              : POSIXct[1:6], format: &quot;2015-04-17 04:10:00&quot; &quot;2015-04-17 04:10:00&quot; &quot;2015-04-17 04:20:00&quot; &quot;2015-04-17 04:15:00&quot; ...
##   .. ..$ variableInfo :'data.frame': 1 obs. of  6 variables:
##   .. .. ..$ parameterCd   : chr &quot;00065&quot;
##   .. .. ..$ parameter_nm  : chr &quot;Gage height, ft&quot;
##   .. .. ..$ parameter_desc: chr &quot;Gage height, feet&quot;
##   .. .. ..$ valueType     : chr &quot;Derived Value&quot;
##   .. .. ..$ param_units   : chr &quot;ft&quot;
##   .. .. ..$ noDataValue   : logi NA
##   .. ..$ statisticInfo:'data.frame': 1 obs. of  2 variables:
##   .. .. ..$ statisticName: chr &quot;&quot;
##   .. .. ..$ statisticCd  : chr &quot;00011&quot;
##  - attr(*, &quot;split_type&quot;)= chr &quot;data.frame&quot;
##  - attr(*, &quot;split_labels&quot;)='data.frame': 2 obs. of  1 variable:
##   ..$ parm_cd: chr [1:2] &quot;00060&quot; &quot;00065&quot;</code></pre>
<p>Now save this data to the local database. Note that this also could have been achieved by specifying the <code>outPath</code> argument to <code>GetUsgsHucData</code>.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">coFiles &lt;-<span class="st"> </span><span class="kw">SaveHucData</span>(coData, <span class="dt">outPath=</span>dbPath)
coFiles</code></pre></div>
</div>
<div id="query-the-local-data" class="section level1">
<h1>Query the local data</h1>
<p>Now we work entirely locally, having grabbed the data of interest. For all HUC8 and products, any of the siteInfo metadata can be retrieved from the local DB. Note that the same site is repeated for multiple products.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">QuerySiteInfo</span>(<span class="kw">c</span>(<span class="st">'station_nm'</span>,<span class="st">'site_no'</span>,<span class="st">'dec_lat_va'</span>,<span class="st">'dec_long_va'</span>), <span class="dt">path=</span>dbPath)</code></pre></div>
<table>
<thead>
<tr class="header">
<th align="left">station_nm</th>
<th align="left">site_no</th>
<th align="right">dec_lat_va</th>
<th align="right">dec_long_va</th>
<th align="left">product</th>
<th align="left">HUC8</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">LEFT HAND CREEK AT HOVER ROAD NEAR LONGMONT, CO</td>
<td align="left">06724970</td>
<td align="right">40.13428</td>
<td align="right">-105.13082</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">ST. VRAIN CREEK BELOW LONGMONT, CO</td>
<td align="left">06725450</td>
<td align="right">40.15742</td>
<td align="right">-105.01539</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">FOURMILE CREEK AT LOGAN MILL ROAD NEAR CRISMAN, CO</td>
<td align="left">06727410</td>
<td align="right">40.04203</td>
<td align="right">-105.36492</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">FOURMILE CREEK AT ORODELL, CO</td>
<td align="left">06727500</td>
<td align="right">40.01867</td>
<td align="right">-105.32625</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">FOURMILE CANYON CREEK NEAR SUNSHINE, CO</td>
<td align="left">06730160</td>
<td align="right">40.05761</td>
<td align="right">-105.34878</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">BOULDER CREEK AT NORTH 75TH ST. NEAR BOULDER, CO</td>
<td align="left">06730200</td>
<td align="right">40.05165</td>
<td align="right">-105.17888</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">BOULDER CREEK AT MOUTH NEAR LONGMONT, CO</td>
<td align="left">06730500</td>
<td align="right">40.13878</td>
<td align="right">-105.02022</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">ST VRAIN CR BLW BOULDER CR AT HWY 119 NR LONGMONT</td>
<td align="left">06730525</td>
<td align="right">40.16035</td>
<td align="right">-105.00783</td>
<td align="left">00060</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">LEFT HAND CREEK AT HOVER ROAD NEAR LONGMONT, CO</td>
<td align="left">06724970</td>
<td align="right">40.13428</td>
<td align="right">-105.13082</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">FOURMILE CREEK AT ORODELL, CO</td>
<td align="left">06727500</td>
<td align="right">40.01867</td>
<td align="right">-105.32625</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">FOURMILE CANYON CREEK NEAR SUNSHINE, CO</td>
<td align="left">06730160</td>
<td align="right">40.05761</td>
<td align="right">-105.34878</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">BOULDER CREEK AT NORTH 75TH ST. NEAR BOULDER, CO</td>
<td align="left">06730200</td>
<td align="right">40.05165</td>
<td align="right">-105.17888</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">BOULDER CREEK AT MOUTH NEAR LONGMONT, CO</td>
<td align="left">06730500</td>
<td align="right">40.13878</td>
<td align="right">-105.02022</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="even">
<td align="left">ST VRAIN CR BLW BOULDER CR AT HWY 119 NR LONGMONT</td>
<td align="left">06730525</td>
<td align="right">40.16035</td>
<td align="right">-105.00783</td>
<td align="left">00065</td>
<td align="left">10190005</td>
</tr>
<tr class="odd">
<td align="left">TOMBIGBEE R AT COFFEEVILLE L&amp;D NR COFFEEVILLE, AL.</td>
<td align="left">02469761</td>
<td align="right">31.75849</td>
<td align="right">-88.12918</td>
<td align="left">00060</td>
<td align="left">03160203</td>
</tr>
<tr class="even">
<td align="left">SATILPA CREEK NEAR COFFEEVILLE AL</td>
<td align="left">02469800</td>
<td align="right">31.74432</td>
<td align="right">-88.02251</td>
<td align="left">00060</td>
<td align="left">03160203</td>
</tr>
<tr class="odd">
<td align="left">BASSETT CREEK AT US HIGHWAY 43 NR THOMASVILLE, AL.</td>
<td align="left">02470072</td>
<td align="right">31.86404</td>
<td align="right">-87.74722</td>
<td align="left">00060</td>
<td align="left">03160203</td>
</tr>
<tr class="even">
<td align="left">TOMBIGBEE R AT COFFEEVILLE L&amp;D NR COFFEEVILLE, AL.</td>
<td align="left">02469761</td>
<td align="right">31.75849</td>
<td align="right">-88.12918</td>
<td align="left">00065</td>
<td align="left">03160203</td>
</tr>
<tr class="odd">
<td align="left">TOMBIGBEE R BL COFFEEVILLE L&amp;D NEAR COFFEEVILLE</td>
<td align="left">02469762</td>
<td align="right">31.75710</td>
<td align="right">-88.12501</td>
<td align="left">00065</td>
<td align="left">03160203</td>
</tr>
<tr class="even">
<td align="left">SATILPA CREEK NEAR COFFEEVILLE AL</td>
<td align="left">02469800</td>
<td align="right">31.74432</td>
<td align="right">-88.02251</td>
<td align="left">00065</td>
<td align="left">03160203</td>
</tr>
<tr class="odd">
<td align="left">TOMBIGBEE RIVER AT STEAMPLANT NR LEROY, AL</td>
<td align="left">02470050</td>
<td align="right">31.48600</td>
<td align="right">-87.90889</td>
<td align="left">00065</td>
<td align="left">03160203</td>
</tr>
<tr class="even">
<td align="left">BASSETT CREEK AT US HIGHWAY 43 NR THOMASVILLE, AL.</td>
<td align="left">02470072</td>
<td align="right">31.86404</td>
<td align="right">-87.74722</td>
<td align="left">00065</td>
<td align="left">03160203</td>
</tr>
<tr class="odd">
<td align="left">TOMBIGBEE R AT COFFEEVILLE L&amp;D NR COFFEEVILLE, AL.</td>
<td align="left">02469761</td>
<td align="right">31.75849</td>
<td align="right">-88.12918</td>
<td align="left">45592</td>
<td align="left">03160203</td>
</tr>
</tbody>
</table>
<p>Say you just want Orodell and you want your code to be readable: translate the name to the code with QuerySiteName (which translates both ways).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dataOrodell &lt;-<span class="st"> </span><span class="kw">QuerySiteData</span>(<span class="kw">QuerySiteName</span>(<span class="st">&quot;FOURMILE CREEK AT ORODELL, CO&quot;</span>, <span class="dt">path=</span>dbPath),
                             <span class="dt">product=</span><span class="st">'00060'</span>, <span class="dt">path=</span>dbPath)
<span class="kw">str</span>(dataOrodell)</code></pre></div>
<pre><code>## 'data.frame':    208824 obs. of  5 variables:
##  $ site_no : chr  &quot;06727500&quot; &quot;06727500&quot; &quot;06727500&quot; &quot;06727500&quot; ...
##  $ dateTime: POSIXct, format: &quot;2011-04-01 06:00:00&quot; &quot;2011-04-01 06:05:00&quot; &quot;2011-04-01 06:10:00&quot; &quot;2011-04-01 06:15:00&quot; ...
##  $ code    : chr  &quot;A&quot; &quot;A&quot; &quot;A&quot; &quot;A&quot; ...
##  $ value   : num  1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 ...
##  $ variable: chr  &quot;X_00060_00011&quot; &quot;X_00060_00011&quot; &quot;X_00060_00011&quot; &quot;X_00060_00011&quot; ...
##  - attr(*, &quot;siteInfo&quot;)='data.frame': 1 obs. of  46 variables:
##   ..$ site_no              : chr &quot;06727500&quot;
##   ..$ agency_cd            : chr &quot;USGS&quot;
##   ..$ dec_lat_va           : num 40
##   ..$ dec_long_va          : num -105
##   ..$ huc_cd               : chr &quot;10190005&quot;
##   ..$ site_tp_cd           : chr &quot;ST&quot;
##   ..$ state_cd             : chr &quot;08&quot;
##   ..$ station_nm           : chr &quot;FOURMILE CREEK AT ORODELL, CO&quot;
##   ..$ tz_cd                : chr &quot;MST&quot;
##   ..$ lat_va               : num 4e+05
##   ..$ long_va              : num 1051934
##   ..$ coord_meth_cd        : chr &quot;N&quot;
##   ..$ coord_acy_cd         : chr &quot;5&quot;
##   ..$ coord_datum_cd       : chr &quot;NAD83&quot;
##   ..$ dec_coord_datum_cd   : chr &quot;NAD83&quot;
##   ..$ district_cd          : chr &quot;08&quot;
##   ..$ county_cd            : chr &quot;013&quot;
##   ..$ country_cd           : chr &quot;US&quot;
##   ..$ land_net_ds          : chr &quot;  NWSES27 T001N R071W&quot;
##   ..$ map_nm               : chr &quot;BOULDER, CO&quot;
##   ..$ map_scale_fc         : chr &quot;  24000&quot;
##   ..$ alt_va               : num 5750
##   ..$ alt_meth_cd          : chr &quot;M&quot;
##   ..$ alt_acy_va           : num 15
##   ..$ alt_datum_cd         : chr &quot;NGVD29&quot;
##   ..$ basin_cd             : chr &quot;06&quot;
##   ..$ topo_cd              : chr &quot;&quot;
##   ..$ instruments_cd       : chr &quot;NNNNYNYNNYNNNNNNNNNNNNNNNNNNNN&quot;
##   ..$ construction_dt      : chr &quot;&quot;
##   ..$ inventory_dt         : chr &quot;20110323&quot;
##   ..$ drain_area_va        : num 24.2
##   ..$ contrib_drain_area_va: num NA
##   ..$ local_time_fg        : chr &quot;Y&quot;
##   ..$ reliability_cd       : chr &quot;&quot;
##   ..$ gw_file_cd           : chr &quot;NYNNNNNN&quot;
##   ..$ nat_aqfr_cd          : chr &quot;&quot;
##   ..$ aqfr_cd              : chr &quot;&quot;
##   ..$ aqfr_type_cd         : chr &quot;&quot;
##   ..$ well_depth_va        : num NA
##   ..$ hole_depth_va        : num NA
##   ..$ depth_src_cd         : chr &quot;&quot;
##   ..$ project_no           : chr &quot;000012000&quot;
##   ..$ timeZoneOffset       : chr &quot;-07:00&quot;
##   ..$ srs                  : chr &quot;EPSG:4326&quot;
##   ..$ startTime            : POSIXct, format: &quot;2011-04-01 06:00:00&quot;
##   ..$ endTime              : POSIXct, format: &quot;2015-04-17 04:10:00&quot;
##  - attr(*, &quot;variableInfo&quot;)='data.frame': 1 obs. of  6 variables:
##   ..$ parameterCd   : chr &quot;00060&quot;
##   ..$ parameter_nm  : chr &quot;Streamflow, ft&amp;#179;/s&quot;
##   ..$ parameter_desc: chr &quot;Discharge, cubic feet per second&quot;
##   ..$ valueType     : chr &quot;Derived Value&quot;
##   ..$ param_units   : chr &quot;ft3/s&quot;
##   ..$ noDataValue   : logi NA
##  - attr(*, &quot;statisticInfo&quot;)='data.frame':    1 obs. of  2 variables:
##   ..$ statisticName: chr &quot;&quot;
##   ..$ statisticCd  : chr &quot;00011&quot;</code></pre>
<p>Now make it “pretty”. The main difference here is meaningful column names and identification of variables and codes in the attributes. We have defined “prettyUsgs” as an S3 class.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">prettyOrodell &lt;-<span class="st"> </span><span class="kw">PrettyUsgs</span>(dataOrodell, <span class="dt">metric=</span><span class="ot">TRUE</span>)
<span class="kw">str</span>(prettyOrodell)</code></pre></div>
<pre><code>## Classes 'prettyUsgs' and 'data.frame':   207496 obs. of  5 variables:
##  $ site_no : chr  &quot;06727500&quot; &quot;06727500&quot; &quot;06727500&quot; &quot;06727500&quot; ...
##  $ POSIXct : POSIXct, format: &quot;2011-04-01 06:00:00&quot; &quot;2011-04-01 06:05:00&quot; &quot;2011-04-01 06:10:00&quot; &quot;2011-04-01 06:15:00&quot; ...
##  $ code    : chr  &quot;A&quot; &quot;A&quot; &quot;A&quot; &quot;A&quot; ...
##  $ value   : num  0.034 0.034 0.034 0.034 0.034 ...
##  $ variable: chr  &quot;Discharge (cms)&quot; &quot;Discharge (cms)&quot; &quot;Discharge (cms)&quot; &quot;Discharge (cms)&quot; ...
##  - attr(*, &quot;siteInfo&quot;)='data.frame': 1 obs. of  46 variables:
##   ..$ site_no              : chr &quot;06727500&quot;
##   ..$ agency_cd            : chr &quot;USGS&quot;
##   ..$ dec_lat_va           : num 40
##   ..$ dec_long_va          : num -105
##   ..$ huc_cd               : chr &quot;10190005&quot;
##   ..$ site_tp_cd           : chr &quot;ST&quot;
##   ..$ state_cd             : chr &quot;08&quot;
##   ..$ station_nm           : chr &quot;FOURMILE CREEK AT ORODELL, CO&quot;
##   ..$ tz_cd                : chr &quot;MST&quot;
##   ..$ lat_va               : num 4e+05
##   ..$ long_va              : num 1051934
##   ..$ coord_meth_cd        : chr &quot;N&quot;
##   ..$ coord_acy_cd         : chr &quot;5&quot;
##   ..$ coord_datum_cd       : chr &quot;NAD83&quot;
##   ..$ dec_coord_datum_cd   : chr &quot;NAD83&quot;
##   ..$ district_cd          : chr &quot;08&quot;
##   ..$ county_cd            : chr &quot;013&quot;
##   ..$ country_cd           : chr &quot;US&quot;
##   ..$ land_net_ds          : chr &quot;  NWSES27 T001N R071W&quot;
##   ..$ map_nm               : chr &quot;BOULDER, CO&quot;
##   ..$ map_scale_fc         : chr &quot;  24000&quot;
##   ..$ alt_va               : num 5750
##   ..$ alt_meth_cd          : chr &quot;M&quot;
##   ..$ alt_acy_va           : num 15
##   ..$ alt_datum_cd         : chr &quot;NGVD29&quot;
##   ..$ basin_cd             : chr &quot;06&quot;
##   ..$ topo_cd              : chr &quot;&quot;
##   ..$ instruments_cd       : chr &quot;NNNNYNYNNYNNNNNNNNNNNNNNNNNNNN&quot;
##   ..$ construction_dt      : chr &quot;&quot;
##   ..$ inventory_dt         : chr &quot;20110323&quot;
##   ..$ drain_area_va        : num 24.2
##   ..$ contrib_drain_area_va: num NA
##   ..$ local_time_fg        : chr &quot;Y&quot;
##   ..$ reliability_cd       : chr &quot;&quot;
##   ..$ gw_file_cd           : chr &quot;NYNNNNNN&quot;
##   ..$ nat_aqfr_cd          : chr &quot;&quot;
##   ..$ aqfr_cd              : chr &quot;&quot;
##   ..$ aqfr_type_cd         : chr &quot;&quot;
##   ..$ well_depth_va        : num NA
##   ..$ hole_depth_va        : num NA
##   ..$ depth_src_cd         : chr &quot;&quot;
##   ..$ project_no           : chr &quot;000012000&quot;
##   ..$ timeZoneOffset       : chr &quot;-07:00&quot;
##   ..$ srs                  : chr &quot;EPSG:4326&quot;
##   ..$ startTime            : POSIXct, format: &quot;2011-04-01 06:00:00&quot;
##   ..$ endTime              : POSIXct, format: &quot;2015-04-17 04:10:00&quot;</code></pre>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">class</span>(prettyOrodell)</code></pre></div>
<pre><code>## [1] &quot;prettyUsgs&quot; &quot;data.frame&quot;</code></pre>
<p>Plot the “pretty”&quot; data.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">oroPlot &lt;-<span class="st"> </span><span class="kw">PlotPrettyUsgs</span>(prettyOrodell)</code></pre></div>
<p><img src="" width="700" height="350" /></p>
</div>
<div id="import-modelled-and-observed-datasets" class="section level1">
<h1>Import modelled and observed datasets</h1>
<p>Set a data path to the Fourmile Creek test case.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dataPath &lt;-<span class="st"> '~/wrfHydroTestCases/Fourmile_Creek_testcase_v2.0/'</span></code></pre></div>
<p>Model 1: Only channel routing turned on (hourly model run).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">modStrd.chrt.fc &lt;-<span class="st"> </span><span class="kw">ReadFrxstPts</span>(<span class="kw">paste0</span>(dataPath, <span class="st">'/run.ChannelRouting/frxst_pts_out.txt'</span>))</code></pre></div>
<p>Model 2: All WRF-Hydro routing options turned on (hourly model run).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">modStrd.allrt.fc &lt;-<span class="st"> </span><span class="kw">ReadFrxstPts</span>(<span class="kw">paste0</span>(dataPath, <span class="st">'/run.FullRouting/frxst_pts_out.txt'</span>))</code></pre></div>
<p>USGS gage observed data at 5-minute intervals. Find the nearest gage to the forecast point in the above files. (The following approach can be used when multiple forecast points are output by the model. The ddply function essentially performs a loop over unique st_id passing the corresponding subset of the data frame modStrd.chrt.fc to the function which just returns the first row’s lon and lat.)</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">library</span>(plyr)
fcLocation &lt;-<span class="st"> </span><span class="kw">ddply</span>(modStrd.chrt.fc, .(st_id), <span class="cf">function</span>(df) df[<span class="dv">1</span>,<span class="kw">c</span>(<span class="st">'st_lon'</span>,<span class="st">'st_lat'</span>)])
near &lt;-<span class="st"> </span><span class="kw">FindUsgsStns</span>(<span class="dt">stnLon=</span><span class="kw">c</span>(fcLocation<span class="op">$</span>st_lon), <span class="dt">stnLat=</span><span class="kw">c</span>(fcLocation<span class="op">$</span>st_lat), <span class="dt">within=</span>.<span class="dv">005</span>)
near</code></pre></div>
<table>
<thead>
<tr class="header">
<th align="right">stnLon</th>
<th align="right">stnLat</th>
<th align="right">within</th>
<th align="left">siteType</th>
<th align="left">hasDataTypeCd</th>
<th align="left">agency_cd</th>
<th align="left">site_no</th>
<th align="left">station_nm</th>
<th align="left">site_tp_cd</th>
<th align="right">dec_lat_va</th>
<th align="right">dec_long_va</th>
<th align="left">colocated</th>
<th align="left">queryTime</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="right">-105.3278</td>
<td align="right">40.01932</td>
<td align="right">0.005</td>
<td align="left">ST</td>
<td align="left">iv</td>
<td align="left">USGS</td>
<td align="left">06727500</td>
<td align="left">FOURMILE CREEK AT ORODELL, CO</td>
<td align="left">ST</td>
<td align="right">40.01867</td>
<td align="right">-105.3263</td>
<td align="left">FALSE</td>
<td align="left">2017-05-01 16:43:19</td>
</tr>
</tbody>
</table>
<p>The following checks to see if the data are local and gets them if not. The ‘00060’ product (streamflow) is returned and then made pretty, including conversion to metric.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">dbPath &lt;-<span class="st"> '~/wrfHydroTestCases/usgsDb/'</span>
obsStr5min.fc &lt;-<span class="st"> </span>
<span class="st">  </span><span class="kw">PrettyUsgs</span>(<span class="kw">QueryHaveSite</span>(near<span class="op">$</span>site_no, <span class="dt">path=</span>dbPath, <span class="dt">ret=</span><span class="st">'00060'</span>, <span class="dt">get=</span><span class="ot">TRUE</span>))
obsStr5min.fc &lt;-<span class="st"> </span>plyr<span class="op">::</span><span class="kw">rename</span>(obsStr5min.fc, <span class="kw">c</span>(<span class="dt">value=</span><span class="st">'q_cms'</span>))</code></pre></div>
</div>
<div id="plot-hydrographs" class="section level1">
<h1>Plot hydrographs</h1>
<p>Compare hydrographs for the full model run.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">PlotFluxCompare</span>(obsStr5min.fc, <span class="st">&quot;q_cms&quot;</span>, modStrd.chrt.fc, <span class="st">&quot;q_cms&quot;</span>, <span class="dt">strDf.mod2=</span>modStrd.allrt.fc, 
     <span class="dt">strCol.mod2=</span><span class="st">&quot;q_cms&quot;</span>, <span class="dt">labelObs=</span><span class="st">&quot;Observed Fourmile Creek at Orodell&quot;</span>, 
     <span class="dt">labelMod1=</span><span class="st">&quot;Channel Routing Only&quot;</span>, <span class="dt">labelMod2=</span><span class="st">&quot;All Routing&quot;</span>, 
     <span class="dt">title=</span><span class="st">&quot;Streamflow: Fourmile Creek&quot;</span>)</code></pre></div>
<p><img src="" width="700" height="350" /></p>
<p>Now limit the plot to the peak May flow period only. The reported stats are updated to the new time period. (Note that the R warning is innocuous because the subset adjusts for timezone, so it’s ok that the timezones don’t match.)</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">PlotFluxCompare</span>(obsStr5min.fc, <span class="st">&quot;q_cms&quot;</span>, modStrd.chrt.fc, <span class="st">&quot;q_cms&quot;</span>, <span class="dt">strDf.mod2=</span>modStrd.allrt.fc, 
     <span class="dt">strCol.mod2=</span><span class="st">&quot;q_cms&quot;</span>, <span class="dt">labelObs=</span><span class="st">&quot;Observed Fourmile Creek at Orodell&quot;</span>, 
     <span class="dt">labelMod1=</span><span class="st">&quot;Channel Routing Only&quot;</span>, <span class="dt">labelMod2=</span><span class="st">&quot;All Routing&quot;</span>, 
     <span class="dt">title=</span><span class="st">&quot;Streamflow: Fourmile Creek&quot;</span>, 
     <span class="dt">stdate=</span><span class="kw">as.POSIXct</span>(<span class="st">&quot;2013-05-01 00:00:00&quot;</span>, <span class="dt">format=</span><span class="st">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, <span class="dt">tz=</span><span class="st">&quot;UTC&quot;</span>), 
     <span class="dt">enddate=</span><span class="kw">as.POSIXct</span>(<span class="st">&quot;2013-05-31 00:00:00&quot;</span>, <span class="dt">format=</span><span class="st">&quot;%Y-%m-%d %H:%M:%S&quot;</span>, <span class="dt">tz=</span><span class="st">&quot;UTC&quot;</span>))</code></pre></div>
<p><img src="" width="700" height="350" /></p>
</div>
<div id="review-flow-duration-curves" class="section level1">
<h1>Review flow duration curves</h1>
<p><b>NOTE</b>: You generally evaluate flow duration curves and staistics over much longer time periods (e.g., multiple years) than what we demo here. To make the test case more portable, we are only evaluating once-a-day model output over 5 months.</p>
<p>Calculate percent exceedances for flow duration curves. Note that we need to subset the observations to match our model run output times, and vice versa.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">obsStr5min.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdc</span>(<span class="kw">subset</span>(obsStr5min.fc, POSIXct <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(modStrd.chrt.fc<span class="op">$</span>POSIXct)))
modStrd.chrt.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdc</span>(<span class="kw">subset</span>(modStrd.chrt.fc, POSIXct <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(obsStr5min.comp.fc<span class="op">$</span>POSIXct)))
modStrd.allrt.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdc</span>(<span class="kw">subset</span>(modStrd.allrt.fc, POSIXct <span class="op">%in%</span><span class="st"> </span><span class="kw">c</span>(obsStr5min.comp.fc<span class="op">$</span>POSIXct)))</code></pre></div>
<p>Compare how the models are doing predicting flow values that will be exceeded 20% of the time. First, calculate the fitted spline functions.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">fdc.obsStr5min.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdcSpline</span>(obsStr5min.comp.fc)
fdc.modStrd.chrt.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdcSpline</span>(modStrd.chrt.comp.fc)
fdc.modStrd.allrt.comp.fc &lt;-<span class="st"> </span><span class="kw">CalcFdcSpline</span>(modStrd.allrt.comp.fc)</code></pre></div>
<p>Then, evaluate at the 20% exceedance percentage (high flows).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">fdc.obsStr5min.comp.fc</span>(<span class="fl">0.2</span>)
<span class="kw">fdc.modStrd.chrt.comp.fc</span>(<span class="fl">0.2</span>)
<span class="kw">fdc.modStrd.allrt.comp.fc</span>(<span class="fl">0.2</span>)</code></pre></div>
<pre><code>## [1] 0.7706495
## [1] 0.8170807
## [1] 0.7931814</code></pre>
<p>Now try the 80% exceedance percentage (low flows).</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">fdc.obsStr5min.comp.fc</span>(<span class="fl">0.8</span>)
<span class="kw">fdc.modStrd.chrt.comp.fc</span>(<span class="fl">0.8</span>)
<span class="kw">fdc.modStrd.allrt.comp.fc</span>(<span class="fl">0.8</span>)</code></pre></div>
<pre><code>## [1] 0.08530777
## [1] 0.1557625
## [1] 0.09120762</code></pre>
<p>Plot flow duration curves for a more complete picture. This tool will do the date matching for us, so no need to subset the datasets.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">PlotFdcCompare</span>(obsStr5min.fc, <span class="st">&quot;q_cms&quot;</span>, modStrd.chrt.fc, <span class="st">&quot;q_cms&quot;</span>, <span class="dt">strDf.mod2=</span>modStrd.allrt.fc, 
     <span class="dt">strCol.mod2=</span><span class="st">&quot;q_cms&quot;</span>, <span class="dt">labelObs=</span><span class="st">&quot;Observed Fourmile Creek&quot;</span>, 
     <span class="dt">labelMod1=</span><span class="st">&quot;Channel Routing Only&quot;</span>, <span class="dt">labelMod2=</span><span class="st">&quot;All Routing&quot;</span>)</code></pre></div>
<pre><code>## [1] &quot;Combined min flow for y-axis (capped at 0.001): 0.03114853126&quot;
## [1] &quot;Combined max flow for y-axis: 2.5201993474&quot;</code></pre>
<p><img src="" width="700" height="350" /></p>
</div>
<div id="review-model-performance-statistics" class="section level1">
<h1>Review model performance statistics</h1>
<p>Calculate model performance stats (special formatting comands hidden). Again, this tool does the date matching for us.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">CalcModPerf</span>(modStrd.chrt.fc, obsStr5min.fc)</code></pre></div>
<table>
<colgroup>
<col width="10%"></col>
<col width="4%"></col>
<col width="6%"></col>
<col width="6%"></col>
<col width="6%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="6%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
</colgroup>
<thead>
<tr class="header">
<th align="center"> </th>
<th align="center">n</th>
<th align="center">nse</th>
<th align="center">nselog</th>
<th align="center">cor</th>
<th align="center">rmse</th>
<th align="center">rmsenorm</th>
<th align="center">bias</th>
<th align="center">msd</th>
<th align="center">mae</th>
<th align="center">errcom</th>
<th align="center">errmaxt</th>
<th align="center">errfdc</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center"><strong>units</strong></td>
<td align="center">count</td>
<td align="center">unitless</td>
<td align="center">unitless</td>
<td align="center">unitless</td>
<td align="center">flux units</td>
<td align="center">unitless</td>
<td align="center">percent</td>
<td align="center">flux units</td>
<td align="center">flux units</td>
<td align="center">hours|days</td>
<td align="center">hours|days</td>
<td align="center">flux units</td>
</tr>
<tr class="even">
<td align="center"><strong>t</strong></td>
<td align="center">232</td>
<td align="center">0.82</td>
<td align="center">0.73</td>
<td align="center">0.93</td>
<td align="center">0.2067</td>
<td align="center">8.31</td>
<td align="center">19.2</td>
<td align="center">0.0846</td>
<td align="center">0.1305</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">0.08</td>
</tr>
<tr class="odd">
<td align="center"><strong>daily</strong></td>
<td align="center">116</td>
<td align="center">0.82</td>
<td align="center">0.73</td>
<td align="center">0.93</td>
<td align="center">0.2067</td>
<td align="center">8.31</td>
<td align="center">19.2</td>
<td align="center">0.0846</td>
<td align="center">0.1305</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0.08</td>
</tr>
<tr class="even">
<td align="center"><strong>monthly</strong></td>
<td align="center">5</td>
<td align="center">0.92</td>
<td align="center">0.7</td>
<td align="center">0.99</td>
<td align="center">0.1044</td>
<td align="center">10.07</td>
<td align="center">21.5</td>
<td align="center">0.0768</td>
<td align="center">0.0806</td>
<td align="center">-0.2</td>
<td align="center">-0.2</td>
<td align="center">NA</td>
</tr>
<tr class="odd">
<td align="center"><strong>yearly</strong></td>
<td align="center">1</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">19.2</td>
<td align="center">0.0846</td>
<td align="center">0.0846</td>
<td align="center">3</td>
<td align="center">-1</td>
<td align="center">NA</td>
</tr>
<tr class="even">
<td align="center"><strong>max10</strong></td>
<td align="center">24</td>
<td align="center">-0.04</td>
<td align="center">-0.08</td>
<td align="center">0.5</td>
<td align="center">0.4806</td>
<td align="center">32.64</td>
<td align="center">15</td>
<td align="center">0.235</td>
<td align="center">0.417</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
</tr>
<tr class="odd">
<td align="center"><strong>min10</strong></td>
<td align="center">24</td>
<td align="center">-82.69</td>
<td align="center">-24.6</td>
<td align="center">0.53</td>
<td align="center">0.078</td>
<td align="center">250.56</td>
<td align="center">152.6</td>
<td align="center">0.076</td>
<td align="center">0.076</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
</tr>
</tbody>
</table>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">CalcModPerf</span>(modStrd.allrt.fc, obsStr5min.fc)</code></pre></div>
<table>
<colgroup>
<col width="10%"></col>
<col width="4%"></col>
<col width="6%"></col>
<col width="6%"></col>
<col width="6%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="6%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
<col width="8%"></col>
</colgroup>
<thead>
<tr class="header">
<th align="center"> </th>
<th align="center">n</th>
<th align="center">nse</th>
<th align="center">nselog</th>
<th align="center">cor</th>
<th align="center">rmse</th>
<th align="center">rmsenorm</th>
<th align="center">bias</th>
<th align="center">msd</th>
<th align="center">mae</th>
<th align="center">errcom</th>
<th align="center">errmaxt</th>
<th align="center">errfdc</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center"><strong>units</strong></td>
<td align="center">count</td>
<td align="center">unitless</td>
<td align="center">unitless</td>
<td align="center">unitless</td>
<td align="center">flux units</td>
<td align="center">unitless</td>
<td align="center">percent</td>
<td align="center">flux units</td>
<td align="center">flux units</td>
<td align="center">hours|days</td>
<td align="center">hours|days</td>
<td align="center">flux units</td>
</tr>
<tr class="even">
<td align="center"><strong>t</strong></td>
<td align="center">116</td>
<td align="center">0.75</td>
<td align="center">0.87</td>
<td align="center">0.9</td>
<td align="center">0.2462</td>
<td align="center">9.89</td>
<td align="center">9.1</td>
<td align="center">0.0399</td>
<td align="center">0.1402</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">0.03</td>
</tr>
<tr class="odd">
<td align="center"><strong>daily</strong></td>
<td align="center">116</td>
<td align="center">0.75</td>
<td align="center">0.87</td>
<td align="center">0.9</td>
<td align="center">0.2462</td>
<td align="center">9.89</td>
<td align="center">9.1</td>
<td align="center">0.0399</td>
<td align="center">0.1402</td>
<td align="center">0</td>
<td align="center">0</td>
<td align="center">0.03</td>
</tr>
<tr class="even">
<td align="center"><strong>monthly</strong></td>
<td align="center">5</td>
<td align="center">0.95</td>
<td align="center">0.95</td>
<td align="center">0.99</td>
<td align="center">0.0867</td>
<td align="center">8.36</td>
<td align="center">7</td>
<td align="center">0.0251</td>
<td align="center">0.0645</td>
<td align="center">-0.6</td>
<td align="center">0</td>
<td align="center">NA</td>
</tr>
<tr class="odd">
<td align="center"><strong>yearly</strong></td>
<td align="center">1</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">9.1</td>
<td align="center">0.0399</td>
<td align="center">0.0399</td>
<td align="center">3</td>
<td align="center">4</td>
<td align="center">NA</td>
</tr>
<tr class="even">
<td align="center"><strong>max10</strong></td>
<td align="center">12</td>
<td align="center">-0.63</td>
<td align="center">-0.51</td>
<td align="center">0.11</td>
<td align="center">0.6034</td>
<td align="center">40.98</td>
<td align="center">14.4</td>
<td align="center">0.2264</td>
<td align="center">0.5365</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
</tr>
<tr class="odd">
<td align="center"><strong>min10</strong></td>
<td align="center">12</td>
<td align="center">-13.12</td>
<td align="center">-6.56</td>
<td align="center">-0.08</td>
<td align="center">0.0321</td>
<td align="center">102.9</td>
<td align="center">49.8</td>
<td align="center">0.0248</td>
<td align="center">0.0252</td>
<td align="center">NA</td>
<td align="center">NA</td>
<td align="center">NA</td>
</tr>
</tbody>
</table>
<p>Help on CalcModPerf gives details on the individual statistics returned.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">help</span>(CalcModPerf)</code></pre></div>
<pre><code>## Using development documentation for CalcModPerf</code></pre>
<div style="border:1px solid; border-radius: 25px; padding: 12px 25px;">
<pre><code>## Using development documentation for CalcModPerf</code></pre>
</div>
<p><br><br> Calculate flow duration curve performance statistics.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">CalcFdcPerf</span>(modStrd.allrt.fc, obsStr5min.fc)</code></pre></div>
<table style="width:60%;">
<colgroup>
<col width="15%"></col>
<col width="11%"></col>
<col width="11%"></col>
<col width="11%"></col>
<col width="11%"></col>
</colgroup>
<thead>
<tr class="header">
<th align="center">p.exceed</th>
<th align="center">q.mod</th>
<th align="center">q.obs</th>
<th align="center">q.err</th>
<th align="center">q.perr</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">0.1</td>
<td align="center">1.43</td>
<td align="center">1.04</td>
<td align="center">0.39</td>
<td align="center">37.5</td>
</tr>
<tr class="even">
<td align="center">0.2</td>
<td align="center">0.79</td>
<td align="center">0.77</td>
<td align="center">0.02</td>
<td align="center">2.6</td>
</tr>
<tr class="odd">
<td align="center">0.3</td>
<td align="center">0.49</td>
<td align="center">0.56</td>
<td align="center">-0.07</td>
<td align="center">-12.5</td>
</tr>
<tr class="even">
<td align="center">0.4</td>
<td align="center">0.33</td>
<td align="center">0.36</td>
<td align="center">-0.03</td>
<td align="center">-8.3</td>
</tr>
<tr class="odd">
<td align="center">0.5</td>
<td align="center">0.25</td>
<td align="center">0.24</td>
<td align="center">0.01</td>
<td align="center">4.2</td>
</tr>
<tr class="even">
<td align="center">0.6</td>
<td align="center">0.17</td>
<td align="center">0.14</td>
<td align="center">0.03</td>
<td align="center">21.4</td>
</tr>
<tr class="odd">
<td align="center">0.7</td>
<td align="center">0.13</td>
<td align="center">0.12</td>
<td align="center">0.01</td>
<td align="center">8.3</td>
</tr>
<tr class="even">
<td align="center">0.8</td>
<td align="center">0.09</td>
<td align="center">0.09</td>
<td align="center">0</td>
<td align="center">0</td>
</tr>
<tr class="odd">
<td align="center">0.9</td>
<td align="center">0.07</td>
<td align="center">0.06</td>
<td align="center">0.01</td>
<td align="center">16.7</td>
</tr>
</tbody>
</table>
<p>Again, help on CalcFdcPerf gives details on the individual statistics returned.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">help</span>(CalcFdcPerf)</code></pre></div>
<pre><code>## Using development documentation for CalcFdcPerf</code></pre>
<div style="border:1px solid; border-radius: 25px; padding: 12px 25px;">
<pre><code>## Using development documentation for CalcFdcPerf</code></pre>
</div>
</div>
<div id="gagesii-attributes" class="section level1">
<h1>GagesII Attributes</h1>
<p>We’ve imported the gages-II atributes to be directly available in R.</p>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r"><span class="kw">head</span>(gages2Attr)</code></pre></div>
<table>
<thead>
<tr class="header">
<th align="left">STAID</th>
<th align="left">STANAME</th>
<th align="left">CLASS</th>
<th align="left">AGGECOREGI</th>
<th align="right">DRAIN_SQKM</th>
<th align="left">HUC02</th>
<th align="right">LAT_GAGE</th>
<th align="right">LNG_GAGE</th>
<th align="left">STATE</th>
<th align="left">HCDN_2009</th>
<th align="left">ACTIVE09</th>
<th align="right">FLYRS1900</th>
<th align="right">FLYRS1950</th>
<th align="right">FLYRS1990</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">01011000</td>
<td align="left">Allagash River near Allagash, Maine</td>
<td align="left">Non-ref</td>
<td align="left">NorthEast</td>
<td align="right">3186.8440</td>
<td align="left">01</td>
<td align="right">47.06961</td>
<td align="right">-69.07954</td>
<td align="left">ME</td>
<td align="left"></td>
<td align="left">yes</td>
<td align="right">78</td>
<td align="right">60</td>
<td align="right">20</td>
</tr>
<tr class="even">
<td align="left">01013500</td>
<td align="left">Fish River near Fort Kent, Maine</td>
<td align="left">Ref</td>
<td align="left">NorthEast</td>
<td align="right">2252.6960</td>
<td align="left">01</td>
<td align="right">47.23739</td>
<td align="right">-68.58264</td>
<td align="left">ME</td>
<td align="left">yes</td>
<td align="left">yes</td>
<td align="right">85</td>
<td align="right">60</td>
<td align="right">20</td>
</tr>
<tr class="odd">
<td align="left">01015800</td>
<td align="left">Aroostook River near Masardis, Maine</td>
<td align="left">Non-ref</td>
<td align="left">NorthEast</td>
<td align="right">2313.7550</td>
<td align="left">01</td>
<td align="right">46.52300</td>
<td align="right">-68.37176</td>
<td align="left">ME</td>
<td align="left"></td>
<td align="left">yes</td>
<td align="right">51</td>
<td align="right">51</td>
<td align="right">19</td>
</tr>
<tr class="even">
<td align="left">01016500</td>
<td align="left">MACHIAS RIVER NEAR ASHLAND, ME</td>
<td align="left">Non-ref</td>
<td align="left">NorthEast</td>
<td align="right">847.7721</td>
<td align="left">01</td>
<td align="right">46.62831</td>
<td align="right">-68.43479</td>
<td align="left">ME</td>
<td align="left"></td>
<td align="left"></td>
<td align="right">32</td>
<td align="right">32</td>
<td align="right">0</td>
</tr>
<tr class="odd">
<td align="left">01017000</td>
<td align="left">Aroostook River at Washburn, Maine</td>
<td align="left">Non-ref</td>
<td align="left">NorthEast</td>
<td align="right">4278.9070</td>
<td align="left">01</td>
<td align="right">46.77729</td>
<td align="right">-68.15719</td>
<td align="left">ME</td>
<td align="left"></td>
<td align="left">yes</td>
<td align="right">79</td>
<td align="right">60</td>
<td align="right">20</td>
</tr>
<tr class="even">
<td align="left">01017060</td>
<td align="left">Hardwood Brook below Glidden Brk nr Caribou, Maine</td>
<td align="left">Non-ref</td>
<td align="left">NorthEast</td>
<td align="right">14.8644</td>
<td align="left">01</td>
<td align="right">46.78361</td>
<td align="right">-67.98917</td>
<td align="left">ME</td>
<td align="left"></td>
<td align="left">yes</td>
<td align="right">0</td>
<td align="right">0</td>
<td align="right">0</td>
</tr>
</tbody>
</table>
<div class="sourceCode"><pre class="sourceCode r"><code class="sourceCode r">?gages2Attr</code></pre></div>
<pre><code>## Using development documentation for gages2Attr</code></pre>
</div>



<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
  (function () {
    var script = document.createElement("script");
    script.type = "text/javascript";
    script.src  = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
    document.getElementsByTagName("head")[0].appendChild(script);
  })();
</script>

</body>
</html>
